<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

<xi:include href="master.html" />
<?python
thumbsize = "270px";
?>
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title py:if="not gallery">Galleries | Yale Club Beijing</title>
    <title py:if="gallery">${gallery.title} | Yale Club Beijing</title>
    <script type="text/javascript">
    //<![CDATA[
    window.addEvent('domready', function(){
        $$$$('.thumb').each(function(item, index){
            var wid = item.getWidth();
            var hei = item.getHeight();
            if (wid > hei) item.style.width = '${thumbsize}';
            else item.style.height = '${thumbsize}';
        });
    });
    //]]>
    </script>
    <style type="text/css">
        .photo{
            height: ${thumbsize};
            width: ${thumbsize};
            float: left;
            margin: 10px;
        }
        .photo div{text-align: center;}
        a img{border:none;}
    </style> 
</head>
<body>
<h1 py:if="not gallery">Galleries</h1>
<h1 py:if="gallery">${gallery.title}</h1>
<div class="gallery" py:if="gallery">
    <div class="text-right"><a href="uploadfile?parentid=${gallery.id}">Upload photo</a></div>
    <div class="photo" py:for="p in gallery.children">
        <div><a href="${p.url}"><img class='thumb' src="${p.src}" /></a></div>
        <div><a href="${p.url}">${p.title}</a></div>
    </div>
</div>
<div class="galleries" py:if="not gallery">
	<div class="photo" py:for="g in galleries">
		<div><a href="galleries?gid=${g.id}"><img class="thumb" src="${g.cover.src if g.cover else '/static/images/gallery.jpg'}"/></a></div>
		<div><b><a href="galleries?gid=${g.id}">${g.title}</a></b></div>
	</div>
</div>
</body>
</html>
